/*
 * @Author: your name
 * @Date: 2020-08-16 14:43:33
 * @LastEditTime: 2020-08-16 14:53:30
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \demo\day02\demo07\main.go
 */
package main

import (
	"fmt"
	"reflect"
)

func reflectType(x interface{}) {
	// 反射获取参数类型
	v := reflect.TypeOf(x)
	fmt.Printf("type:%v\n", v)
}

// ------------------------------------------

type myInt int64

func reflectInfo(x interface{}) {
	t := reflect.TypeOf(x)
	fmt.Printf("type:%v kind:%v\n", t.Name(), t.Kind())
}

func main() {
	var a float32 = 3.15
	reflectType(a)
	var b int = 100
	reflectType(b)
	// ------------------------------------------
	var a1 *float32
	var b1 myInt
	var c1 rune
	reflectInfo(a1)
	reflectInfo(b1)
	reflectInfo(c1)
	// ------------------------------------------
	type person struct {
		name string
		age  int
	}
	type book struct{ title string }

	var d = person{
		name: "aaa",
		age:  12,
	}
	var e = book{title: "dddd"}
	reflectInfo(d)
	reflectInfo(e)
}
